﻿Public Class Rproyecto

    Public Shared Function SeleccionarTodo(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean) As List(Of Eproyecto)
        Dim proyectos As List(Of Eproyecto) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                proyectos = Dproyecto.SeleccionarTodo(descEmpresa)
                If proyectos Is Nothing Then proyectos = New List(Of Eproyecto)
                If DisplaySelect Then proyectos.Insert(0, New Eproyecto("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return proyectos
    End Function
    Public Shared Function SeleccionarXUsuario(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal idUsuario As Int32) As List(Of Eproyecto)
        Dim proyectos As List(Of Eproyecto) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                proyectos = Dproyecto.SeleccionarXUsuario(descEmpresa, idUsuario)
                If proyectos Is Nothing Then proyectos = New List(Of Eproyecto)
                If DisplaySelect Then proyectos.Insert(0, New Eproyecto("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return proyectos
    End Function
    Public Shared Function SeleccionarTodoXproyecto(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal pProyecto As Eproyecto) As List(Of Eproyecto)
        Dim proyectos As List(Of Eproyecto) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                proyectos = Dproyecto.SeleccionarTodoXproyecto(descEmpresa, pProyecto)
                If proyectos Is Nothing Then proyectos = New List(Of Eproyecto)
                If DisplaySelect Then proyectos.Insert(0, New Eproyecto("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return proyectos
    End Function
    Public Shared Function SeleccionarXPersonal(ByVal descEmpresa As String, ByVal idUsuario As Int32) As List(Of Eproyecto)
        Dim proyectos As List(Of Eproyecto) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                proyectos = Dproyecto.SeleccionarXPersonal(descEmpresa, idUsuario)
                If proyectos Is Nothing Then proyectos = New List(Of Eproyecto)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return proyectos
    End Function
    Public Shared Function SeleccionarDisponibles(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal idUsuario As Int32) As List(Of Eproyecto)
        Dim proyectos As List(Of Eproyecto) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                proyectos = Dproyecto.SeleccionarDisponibles(descEmpresa, idUsuario)
                If proyectos Is Nothing Then proyectos = New List(Of Eproyecto)
                If DisplaySelect Then proyectos.Insert(0, New Eproyecto("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return proyectos
    End Function
    Public Shared Function grabarProyecto(ByVal descEmpresa As String, ByVal idUsuario As Int32, ByVal idProyecto As Int32, ByRef idUsuarioProyecto As Int32) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Dproyecto.grabarProyecto(descEmpresa, idUsuario, idProyecto, idUsuarioProyecto)

                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function EliminarProyecto(ByVal descEmpresa As String, ByVal idPersonal As Int32, ByVal idProyecto As Int32) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Dproyecto.EliminarProyecto(descEmpresa, idPersonal, idProyecto)

                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    'Public Shared Function Añadir(ByVal ent As Eaccion) As Boolean
    '    Dim resultado As Boolean = False

    '    Dim options As New TransactionOptions
    '    options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
    '    options.Timeout = New TimeSpan(0, 2, 0)

    '    Using scope As New TransactionScope(TransactionScopeOption.Required, options)
    '        Try
    '            resultado = Daccion.Añadir(ent)
    '            scope.Complete()
    '        Catch ex As Exception
    '            Throw
    '        End Try
    '    End Using

    '    Return resultado
    'End Function
    'Public Shared Function Editar(ByVal ent As Eaccion) As Boolean
    '    Dim options As New TransactionOptions
    '    options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
    '    options.Timeout = New TimeSpan(0, 2, 0)

    '    Using scope As New TransactionScope(TransactionScopeOption.Required, options)
    '        Try
    '            Daccion.Editar(ent)
    '            scope.Complete()
    '        Catch ex As Exception
    '            Throw
    '        End Try
    '    End Using
    'End Function
    'Public Shared Function Eliminar(ByVal idAccion As Int32) As Boolean
    '    Dim options As New TransactionOptions
    '    options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
    '    options.Timeout = New TimeSpan(0, 2, 0)

    '    Using scope As New TransactionScope(TransactionScopeOption.Required, options)
    '        Try
    '            Daccion.Eliminar(idAccion)
    '            scope.Complete()
    '        Catch ex As Exception
    '            Throw
    '        End Try
    '    End Using
    'End Function

End Class
